<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎注册</title>
</head>
<body>
<div class="form-div">
    <div class="reg-content">
        <h1>欢迎注册</h1>
        <span>已有帐号？</span><a href="#">登录</a>
    </div>
    <form id="reg-form" action="#" method="get">
        <table>
            <tr>
                <td>用户名</td>
                <td class="inputs">
                    <input name="username" type="text" id="username">
                    <br>
                    <span id="username_err" class="err_msg" style="display: none">用户名不太受欢迎</span>
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td class="inputs">
                    <input name="password" type="text" id="password">
                    <br>
                    <span id="password_err" class="err_msg" style="display: none">密码格式错误</span>
                </td>
            </tr>
            <tr>
                <td>手机号</td>
                <td class="inputs">
                    <input name="phoneNumber" type="text" id="phoneNumber">
                    <br>
                    <span id="phoneNumber_err" class="err_msg" style="display: none">手机号格式错误</span>
                </td>
            </tr>
        </table>
        <br>
        <div class="buttons">
            <input value="点我注册" type="submit" id="reg_btn">
        </div>
        <br class="clear">
    </form>
</div>
<script>
    var usernameInput = document.getElementById("username");
    usernameInput.onblur = function () {
        var username = usernameInput.value.trim();
        if (username.length >= 3 && username.length <= 6) {
            document.getElementById("username_err").style.display = 'none';
        } else {
            document.getElementById("username_err").style.display = '';
        }
    }

    var passwordInput = document.getElementById("password");
    passwordInput.onblur = function () {
        var password = passwordInput.value.trim();
        if (password.length >= 6 && password.length <= 12) {
            document.getElementById("password_err").style.display = 'none';
        } else {
            document.getElementById("password_err").style.display = '';
        }
    }

    var phoneNumberInput = document.getElementById("phoneNumber");
    phoneNumberInput.onblur = function () {
        var phoneNumber = phoneNumberInput.value.trim();
        if (phoneNumber.length == 11) {
            document.getElementById("phoneNumber_err").style.display = 'none';
        } else {
            document.getElementById("phoneNumber_err").style.display = '';
        }
    }
</script>
</body>
</html>